import instance from "../../../utils/request";
import { baseURL } from "../../../config";

//渲染列表方法
export const _categories = async (params) => {
  try {
    const res = await instance.get(
      baseURL + `categories/all-categories/${params[0]}/${params[1]}`,
      {
        headers: {
          "Content-Type": "application/json",
        },
      }
    );
    console.log(res);

    return [res.data.list];
  } catch (err) {
    console.log(err);
  }
};
//新增分类方法
export const _add = async (params) => {
  try {
    const res = await instance.post("categories/category", params, {
      headers: {
        "Content-Type": "application/json",
      },
    });
  } catch (err) {}
};

//删除分类方法
export const _delete = async (params) => {
  try {
    const res = await instance.delete(
      baseURL + `categories/category/${params.categoryId}/${params.curToal}`,
      {
        headers: {
          "Content-Type": "application/json",
        },
      }
    );
  } catch (err) {
    console.log("error", err);
  }
};
